﻿/*****************************************
 * LmgCMS
 * 系统配置
 * 站点管理
 * 新闻管理
 * 友情链接
 * 评论管理
 * 菜单管理
 * 菜单元素
 * 组织机构
 * 角色管理
 * 用户管理
 * 多对多关系集中映射
 * 计划任务
 * 系统日志
 * 系统消息
********************************************/
--系统配置
 if exists (select * from sysobjects where id = OBJECT_ID('Setting') and OBJECTPROPERTY(id, 'IsUserTable') = 1) 
DROP TABLE Setting
CREATE TABLE [dbo].[Setting](
	[ID] [NVARCHAR](200) NOT NULL default(newid()),
	[Name] [NVARCHAR](200) NULL,
	[Value] [NVARCHAR](200) NULL,
	[StoreId] [INT] NULL,
	[OrderBy] [INT] NULL,
	[AddTime] [DATETIME] NOT NULL default(getdate()),
PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'系统配置' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Setting'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Setting', @level2type=N'COLUMN',@level2name=N'ID'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Setting', @level2type=N'COLUMN',@level2name=N'Name'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'值' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Setting', @level2type=N'COLUMN',@level2name=N'Value'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'仓库' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Setting', @level2type=N'COLUMN',@level2name=N'StoreId'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排序' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Setting', @level2type=N'COLUMN',@level2name=N'OrderBy'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'添加时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Setting', @level2type=N'COLUMN',@level2name=N'AddTime'
GO
--站点管理
 if exists (select * from sysobjects where id = OBJECT_ID('Site') and OBJECTPROPERTY(id, 'IsUserTable') = 1) 
DROP TABLE [Site]
CREATE TABLE [dbo].[Site](
	[ID] [NVARCHAR](200) NOT NULL default(newid()),
	[Name] [NVARCHAR](200) NULL,
	[SiteUrl] [NVARCHAR](200) NULL,	--网站域名
	[SiteLogo] [NVARCHAR](200) NULL,--网站Logo
	[Summary] [NVARCHAR](200) NULL,	--网站描述
	[SiteTel] [NVARCHAR](200) NULL,	--公司电话
	[SiteFax] [NVARCHAR](200) NULL,	--公司传真
	[SiteEmail] [NVARCHAR](200) NULL,--公司邮箱
	[QQ] [NVARCHAR](200) NULL,	--公司客服QQ
	[WeiXin] [NVARCHAR](200) NULL,	--微信公众号图片
	[WeiBo] [NVARCHAR](200) NULL,	--微博链接地址或者二维码
	[SiteAddress] [NVARCHAR](200) NULL,	--公司地址
	[SiteCode] [NVARCHAR](200) NULL,	--网站备案号其它等信息
	[SeoTitle] [NVARCHAR](200) NULL,	--网站SEO标题
	[SeoKey] [NVARCHAR](200) NULL,	--网站SEO关键字
	[SeoDescribe] [NVARCHAR](200) NULL,	--网站SEO描述
	[SiteCopyright] [NVARCHAR](200) NULL,	--网站版权等信息
    [Open] [INT] NULL,	  --网站开启关闭状态 1开启
	[CloseInfo] [NVARCHAR](200) NULL,	--如果状态关闭，请输入关闭网站原因
	[OrderBy] [INT] NULL,
	[AddTime] [DATETIME] NOT NULL default(getdate()),
PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'站点管理' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Site'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Site', @level2type=N'COLUMN',@level2name=N'ID'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'网站名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Site', @level2type=N'COLUMN',@level2name=N'Name'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'网站域名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Site', @level2type=N'COLUMN',@level2name=N'SiteUrl'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'网站描述' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Site', @level2type=N'COLUMN',@level2name=N'Summary'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'公司电话' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Site', @level2type=N'COLUMN',@level2name=N'SiteTel'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'公司传真' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Site', @level2type=N'COLUMN',@level2name=N'SiteFax'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'公司邮箱' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Site', @level2type=N'COLUMN',@level2name=N'SiteEmail'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'QQ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Site', @level2type=N'COLUMN',@level2name=N'QQ'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'微信' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Site', @level2type=N'COLUMN',@level2name=N'WeiXin'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'微博' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Site', @level2type=N'COLUMN',@level2name=N'WeiBo'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'公司地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Site', @level2type=N'COLUMN',@level2name=N'SiteAddress'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'网站备案号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Site', @level2type=N'COLUMN',@level2name=N'SiteCode'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'网站SEO标题' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Site', @level2type=N'COLUMN',@level2name=N'SeoTitle'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'网站SEO关键字' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Site', @level2type=N'COLUMN',@level2name=N'SeoKey'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'网站SEO描述' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Site', @level2type=N'COLUMN',@level2name=N'SeoDescribe'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'版权信息' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Site', @level2type=N'COLUMN',@level2name=N'SiteCopyright'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'关闭网站' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Site', @level2type=N'COLUMN',@level2name=N'Open'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'关闭原因' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Site', @level2type=N'COLUMN',@level2name=N'CloseInfo'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排序' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Site', @level2type=N'COLUMN',@level2name=N'OrderBy'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'添加时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Site', @level2type=N'COLUMN',@level2name=N'AddTime'
GO
 --新闻管理
if exists (select * from sysobjects where id = OBJECT_ID('News') and OBJECTPROPERTY(id, 'IsUserTable') = 1) 
DROP TABLE [News]
CREATE TABLE [News](
    [ID] [varchar](255) primary key DEFAULT(NEWID()) ,--ID
    [Category] [varchar](255) NULL,--分类
    [Title] [varchar](255) NULL,--标题
    [FTitle] [varchar](255) NULL,--副标题 
    [TitlePic] [varchar](255) NULL,--封面
    [KeyBoard] [varchar](255) NULL,--关键字 
    [SmallText] [varchar](255) NULL,--简介
    [Url] [varchar](255) NULL,--外链
    [Befrom] [varchar](255) DEFAULT('本站') NULL,--来源
    [Author] [varchar](255) DEFAULT('本站') NULL,--作者
    [IsGood] int DEFAULT(0) NULL,--1为推荐，0为不推荐
    [IsDokey] int DEFAULT(0) NULL,--是否替换内容关键字	1为替换 ，0为不替换
    [CloseComment] int DEFAULT(0)  NULL,--是否关闭评论	1为关闭评论，0为不关闭评论
    [OrderBy] int DEFAULT(0)  NULL,
    [AddTime] datetime DEFAULT(getdate()) NULL,-- 添加时间
)
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'新闻管理' , @level0type=N'SCHEMA',@level0name=N'dbo', 
@level1type=N'TABLE',@level1name=N'News'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', 
@level1type=N'TABLE',@level1name=N'News', @level2type=N'COLUMN',@level2name=N'Id'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'分类' , @level0type=N'SCHEMA',@level0name=N'dbo', 
@level1type=N'TABLE',@level1name=N'News', @level2type=N'COLUMN',@level2name=N'Category'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'标题' , @level0type=N'SCHEMA',@level0name=N'dbo', 
@level1type=N'TABLE',@level1name=N'News', @level2type=N'COLUMN',@level2name=N'Title'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'副标题' , @level0type=N'SCHEMA',@level0name=N'dbo', 
@level1type=N'TABLE',@level1name=N'News', @level2type=N'COLUMN',@level2name=N'FTitle'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'封面' , @level0type=N'SCHEMA',@level0name=N'dbo', 
@level1type=N'TABLE',@level1name=N'News', @level2type=N'COLUMN',@level2name=N'TitlePic'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'关键字' , @level0type=N'SCHEMA',@level0name=N'dbo', 
@level1type=N'TABLE',@level1name=N'News', @level2type=N'COLUMN',@level2name=N'KeyBoard'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'简介' , @level0type=N'SCHEMA',@level0name=N'dbo', 
@level1type=N'TABLE',@level1name=N'News', @level2type=N'COLUMN',@level2name=N'SmallText'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'外链' , @level0type=N'SCHEMA',@level0name=N'dbo', 
@level1type=N'TABLE',@level1name=N'News', @level2type=N'COLUMN',@level2name=N'Url'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'来源' , @level0type=N'SCHEMA',@level0name=N'dbo', 
@level1type=N'TABLE',@level1name=N'News', @level2type=N'COLUMN',@level2name=N'Befrom'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'作者' , @level0type=N'SCHEMA',@level0name=N'dbo', 
@level1type=N'TABLE',@level1name=N'News', @level2type=N'COLUMN',@level2name=N'Author'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'推荐' , @level0type=N'SCHEMA',@level0name=N'dbo', 
@level1type=N'TABLE',@level1name=N'News', @level2type=N'COLUMN',@level2name=N'IsGood'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'替换内容关键字' , @level0type=N'SCHEMA',@level0name=N'dbo', 
@level1type=N'TABLE',@level1name=N'News', @level2type=N'COLUMN',@level2name=N'IsDokey'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'关闭评论' , @level0type=N'SCHEMA',@level0name=N'dbo', 
@level1type=N'TABLE',@level1name=N'News', @level2type=N'COLUMN',@level2name=N'CloseComment'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排序' , @level0type=N'SCHEMA',@level0name=N'dbo', 
@level1type=N'TABLE',@level1name=N'News', @level2type=N'COLUMN',@level2name=N'OrderBy'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'添加时间' , @level0type=N'SCHEMA',@level0name=N'dbo', 
@level1type=N'TABLE',@level1name=N'News', @level2type=N'COLUMN',@level2name=N'AddTime'
GO
 --新闻内容
if exists (select * from sysobjects where id = OBJECT_ID('NewsData') and OBJECTPROPERTY(id, 'IsUserTable') = 1) 
DROP TABLE [NewsData]
CREATE TABLE [NewsData](
    [ID] [varchar](255) primary key,--newsID
    [NewsText] [varchar](MAX) NULL,--内容
    [OrderBy] int DEFAULT(0)  NULL,
    [AddTime] datetime DEFAULT(getdate()) NULL,-- 添加时间
)
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'新闻内容' , @level0type=N'SCHEMA',@level0name=N'dbo', 
@level1type=N'TABLE',@level1name=N'NewsData'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'ID' , @level0type=N'SCHEMA',@level0name=N'dbo', 
@level1type=N'TABLE',@level1name=N'NewsData', @level2type=N'COLUMN',@level2name=N'Id'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内容' , @level0type=N'SCHEMA',@level0name=N'dbo', 
@level1type=N'TABLE',@level1name=N'NewsData', @level2type=N'COLUMN',@level2name=N'NewsText'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排序' , @level0type=N'SCHEMA',@level0name=N'dbo', 
@level1type=N'TABLE',@level1name=N'NewsData', @level2type=N'COLUMN',@level2name=N'OrderBy'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'添加时间' , @level0type=N'SCHEMA',@level0name=N'dbo', 
@level1type=N'TABLE',@level1name=N'NewsData', @level2type=N'COLUMN',@level2name=N'AddTime'
GO
--友情链接
if exists (select * from sysobjects where id = OBJECT_ID('Friendlink') and OBJECTPROPERTY(id, 'IsUserTable') = 1) 
DROP TABLE Friendlink
CREATE TABLE Friendlink(
	[ID] [varchar](255) primary key DEFAULT(NEWID()) ,--ID
	[Name] [NVARCHAR](200) NULL,
	[Url] [NVARCHAR](200) NULL,
	[Description] [NVARCHAR](200) NULL,
	[Icon] [NVARCHAR](200) NULL,
	[Category] [varchar](255) NULL,--分类
	[OrderBy] [INT] NULL,
	[Status] [INT] NULL,
	[AddTime] [DATETIME] NOT NULL default(getdate()),
PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'友情链接' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Friendlink'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Friendlink', @level2type=N'COLUMN',@level2name=N'Name'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Url' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Friendlink', @level2type=N'COLUMN',@level2name=N'Url'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'描述' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Friendlink', @level2type=N'COLUMN',@level2name=N'Description'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'图标' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Friendlink', @level2type=N'COLUMN',@level2name=N'Icon'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'分类' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Friendlink', @level2type=N'COLUMN',@level2name=N'Category'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排序' , @level0type=N'SCHEMA',@level0name=N'dbo',  @level1type=N'TABLE',@level1name=N'Friendlink', @level2type=N'COLUMN',@level2name=N'OrderBy'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否可用' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Friendlink', @level2type=N'COLUMN',@level2name=N'Status'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'添加时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Friendlink', @level2type=N'COLUMN',@level2name=N'AddTime'
GO
--评论管理
if exists (select * from sysobjects where id = OBJECT_ID('Comment') and OBJECTPROPERTY(id, 'IsUserTable') = 1) 
DROP TABLE Comment
CREATE TABLE Comment(
	[ID] [nvarchar](200) NOT NULL DEFAULT(NEWID()) ,--ID
	[ParentID] [nvarchar](200) NULL,
	[UserID] [nvarchar](200) NULL,
	[TableID] [nvarchar](200) NULL,
	[TableName] [nvarchar](200) NULL,
	[Message] [nvarchar](200) NULL,
	[IP] [nvarchar](200) NULL,
	[Status] [nvarchar](200) NULL,
	[Name] [nvarchar](200) NULL,	
	[OrderBy] [int] NULL,
	[AddTime] [datetime] NOT NULL  default(getdate()),
PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'评论管理' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Comment'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Comment', @level2type=N'COLUMN',@level2name=N'ID'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'上一级' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Comment', @level2type=N'COLUMN',@level2name=N'ParentID'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发布人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Comment', @level2type=N'COLUMN',@level2name=N'UserID'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'表ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Comment', @level2type=N'COLUMN',@level2name=N'TableID'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'表名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Comment', @level2type=N'COLUMN',@level2name=N'TableName'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'评论内容' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Comment', @level2type=N'COLUMN',@level2name=N'Message'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'评论IP' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Comment', @level2type=N'COLUMN',@level2name=N'IP'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'评论状态' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Comment', @level2type=N'COLUMN',@level2name=N'Status'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Comment', @level2type=N'COLUMN',@level2name=N'Name'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'排序' , @level0type=N'SCHEMA',@level0name=N'dbo',  @level1type=N'TABLE',@level1name=N'Comment', @level2type=N'COLUMN',@level2name=N'OrderBy'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'添加时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Comment', @level2type=N'COLUMN',@level2name=N'AddTime'
GO
--多对多关系集中映射
if exists (select * from sysobjects where id = OBJECT_ID('Relevance') and OBJECTPROPERTY(id, 'IsUserTable') = 1) 
DROP TABLE Relevance
CREATE TABLE [dbo].[Relevance](
	[ID] [nvarchar](200) NOT NULL DEFAULT(NEWID()) ,--ID
	[Description] [nvarchar](200) NULL,
	[Key] [nvarchar](200) NULL,
	[Status] [int] NULL,
	[FirstId] [nvarchar](200) NULL,
	[SecondId] [nvarchar](200) NULL,
	[ThirdId] [nvarchar](200) NULL,
	[ExtendInfo] [nvarchar](200) NULL,
	[OrderBy] [int] NULL,
	[AddTime] [datetime] NOT NULL  default(getdate()),
PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'多对多关系集中映射' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Relevance'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'描述' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Relevance', @level2type=N'COLUMN',@level2name=N'Description'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'映射标识' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Relevance', @level2type=N'COLUMN',@level2name=N'Key'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'状态' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Relevance', @level2type=N'COLUMN',@level2name=N'Status'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第一个表主键ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Relevance', @level2type=N'COLUMN',@level2name=N'FirstId'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第二个表主键ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Relevance', @level2type=N'COLUMN',@level2name=N'SecondId'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'第三个主键' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Relevance', @level2type=N'COLUMN',@level2name=N'ThirdId'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'扩展信息' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Relevance', @level2type=N'COLUMN',@level2name=N'ExtendInfo'
GO
-- 菜单管理
if exists (select * from sysobjects where id = OBJECT_ID('Menu') and OBJECTPROPERTY(id, 'IsUserTable') = 1) 
DROP TABLE Menu
CREATE TABLE [dbo].[Menu](
	[ID] [nvarchar](200) NOT NULL,
	[IsDelete] [int] NULL,
	[DeleteUserID] [nvarchar](200) NULL,
	[DeleteTime] [nvarchar](200) NULL,
	[Url] [nvarchar](200) NULL,
	[Icon] [nvarchar](200) NULL,
	[Status] [int] NULL,
	[Code] [nvarchar](200) NULL,
	[IsSys] [bit] NULL,
	[Name] [nvarchar](200) NULL,
	[ParentID] [nvarchar](200) NULL,
	[OrderBy] [int] NULL,
	[AddTime] [datetime] NOT NULL  default(getdate()),
PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'菜单管理' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Menu'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'软删除' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Menu', @level2type=N'COLUMN',@level2name=N'IsDelete'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'软删除用户' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Menu', @level2type=N'COLUMN',@level2name=N'DeleteUserID'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'软删除时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Menu', @level2type=N'COLUMN',@level2name=N'DeleteTime'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'URL' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Menu', @level2type=N'COLUMN',@level2name=N'Url'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'图标' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Menu', @level2type=N'COLUMN',@level2name=N'Icon'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'当前状态' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Menu', @level2type=N'COLUMN',@level2name=N'Status'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'模块标识' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Menu', @level2type=N'COLUMN',@level2name=N'Code'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否系统模块' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Menu', @level2type=N'COLUMN',@level2name=N'IsSys'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Menu', @level2type=N'COLUMN',@level2name=N'Name'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'上一级' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Menu', @level2type=N'COLUMN',@level2name=N'ParentID'
GO
-- 菜单元素
if exists (select * from sysobjects where id = OBJECT_ID('MenuElement') and OBJECTPROPERTY(id, 'IsUserTable') = 1) 
DROP TABLE MenuElement
CREATE TABLE [dbo].[MenuElement](
	[ID] [nvarchar](200) NOT NULL,
	[ModuleId] [nvarchar](200) NULL,
	[DomId] [nvarchar](200) NULL,
	[Name] [nvarchar](200) NULL,
	[Icon] [nvarchar](200) NULL,
	[Location] [int] NULL,
	[Attr] [nvarchar](200) NULL,
	[Script] [nvarchar](200) NULL,
	[Class] [nvarchar](200) NULL,
	[Remark] [nvarchar](200) NULL,
	[OrderBy] [int] NULL,
	[AddTime] [datetime] NOT NULL  default(getdate()),
PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'菜单元素' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'MenuElement'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'功能模块Id' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'MenuElement', @level2type=N'COLUMN',@level2name=N'ModuleId'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'DOM ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'MenuElement', @level2type=N'COLUMN',@level2name=N'DomId'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'MenuElement', @level2type=N'COLUMN',@level2name=N'Name'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'图标' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'MenuElement', @level2type=N'COLUMN',@level2name=N'Icon'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'位置' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'MenuElement', @level2type=N'COLUMN',@level2name=N'Location'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'元素附加属性' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'MenuElement', @level2type=N'COLUMN',@level2name=N'Attr'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'元素调用脚本' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'MenuElement', @level2type=N'COLUMN',@level2name=N'Script'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'元素样式' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'MenuElement', @level2type=N'COLUMN',@level2name=N'Class'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'MenuElement', @level2type=N'COLUMN',@level2name=N'Remark'
GO

-- 组织表
if exists (select * from sysobjects where id = OBJECT_ID('Organize') and OBJECTPROPERTY(id, 'IsUserTable') = 1) 
DROP TABLE Organize
CREATE TABLE [dbo].[Organize](
	[ID] [nvarchar](200) NOT NULL,
	[TenantId] [nvarchar](200) NULL,
	[IsDelete] [int] NULL,
	[DeleteUserID] [nvarchar](200) NULL,
	[DeleteTime] [nvarchar](200) NULL,
	[Icon] [nvarchar](200) NULL,
	[Status] [int] NULL,
	[EndCode] [nvarchar](200) NULL,
	[ShortName] [nvarchar](200) NULL,
	[CategoryId] [nvarchar](200) NULL,
	[ManagerId] [nvarchar](200) NULL,
	[Mobile] [nvarchar](200) NULL,
	[AreaId] [nvarchar](200) NULL,
	[Name] [nvarchar](200) NULL,
	[ParentID] [nvarchar](200) NULL,
	[OrderBy] [int] NULL,
	[AddTime] [datetime] NOT NULL default(getdate()),
PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'组织表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Organize'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'所属租户' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Organize', @level2type=N'COLUMN',@level2name=N'TenantId'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'软删除' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Organize', @level2type=N'COLUMN',@level2name=N'IsDelete'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'软删除用户' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Organize', @level2type=N'COLUMN',@level2name=N'DeleteUserID'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'软删除时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Organize', @level2type=N'COLUMN',@level2name=N'DeleteTime'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'图标' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Organize', @level2type=N'COLUMN',@level2name=N'Icon'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'当前状态' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Organize', @level2type=N'COLUMN',@level2name=N'Status'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'编码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Organize', @level2type=N'COLUMN',@level2name=N'EndCode'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'简称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Organize', @level2type=N'COLUMN',@level2name=N'ShortName'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'分类' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Organize', @level2type=N'COLUMN',@level2name=N'CategoryId'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'负责人' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Organize', @level2type=N'COLUMN',@level2name=N'ManagerId'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'手机' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Organize', @level2type=N'COLUMN',@level2name=N'Mobile'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'归属区域' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Organize', @level2type=N'COLUMN',@level2name=N'AreaId'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Organize', @level2type=N'COLUMN',@level2name=N'Name'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'上一级' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Organize', @level2type=N'COLUMN',@level2name=N'ParentID'
GO
-- 角色表
if exists (select * from sysobjects where id = OBJECT_ID('Role') and OBJECTPROPERTY(id, 'IsUserTable') = 1) 
DROP TABLE [Role]
CREATE TABLE [dbo].[Role](
	[ID] [nvarchar](200) NOT NULL,
	[IsDelete] [int] NULL,
	[DeleteUserID] [nvarchar](200) NULL,
	[DeleteTime] [nvarchar](200) NULL,
	[OrganizeId] [nvarchar](200) NULL,
	[Category] [int] NULL,
	[EnCode] [nvarchar](200) NULL,
	[Name] [nvarchar](200) NULL,
	[Type] [nvarchar](200) NULL,
	[AllowEdit] [bit] NULL,
	[AllowDelete] [bit] NULL,
	[Status] [int] NULL,
	[Description] [nvarchar](200) NULL,
	[OrderBy] [int] NULL,
	[AddTime] [datetime] NOT NULL  default(getdate()),
PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'角色表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Role'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'软删除' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Role', @level2type=N'COLUMN',@level2name=N'IsDelete'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'软删除用户' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Role', @level2type=N'COLUMN',@level2name=N'DeleteUserID'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'软删除时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Role', @level2type=N'COLUMN',@level2name=N'DeleteTime'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'归属组织' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Role', @level2type=N'COLUMN',@level2name=N'OrganizeId'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'分类' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Role', @level2type=N'COLUMN',@level2name=N'Category'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'角色编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Role', @level2type=N'COLUMN',@level2name=N'EnCode'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'角色名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Role', @level2type=N'COLUMN',@level2name=N'Name'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'角色类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Role', @level2type=N'COLUMN',@level2name=N'Type'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'允许编辑' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Role', @level2type=N'COLUMN',@level2name=N'AllowEdit'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'允许删除' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Role', @level2type=N'COLUMN',@level2name=N'AllowDelete'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'有效' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Role', @level2type=N'COLUMN',@level2name=N'Status'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'说明' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Role', @level2type=N'COLUMN',@level2name=N'Description'
GO
-- 角色表
if exists (select * from sysobjects where id = OBJECT_ID('User') and OBJECTPROPERTY(id, 'IsUserTable') = 1) 
DROP TABLE [User]
CREATE TABLE [dbo].[User](
	[ID] [nvarchar](200) NOT NULL,
	[TenantId] [nvarchar](200) NULL,
	[IsDelete] [int] NULL,
	[DeleteUserID] [nvarchar](200) NULL,
	[DeleteTime] [nvarchar](200) NULL,
	[Account] [nvarchar](200) NULL,
	[Password] [nvarchar](200) NULL,
	[Name] [nvarchar](200) NULL,
	[Sex] [int] NULL,
	[Status] [int] NULL,
	[Mobile] [nvarchar](200) NULL,
	[Email] [nvarchar](200) NULL,
	[Nationality] [nvarchar](200) NULL,
	[Faith] [nvarchar](200) NULL,
	[Health] [nvarchar](200) NULL,
	[IdcardType] [nvarchar](200) NULL,
	[Idcard] [nvarchar](200) NULL,
	[Address] [nvarchar](200) NULL,
	[Zipcode] [nvarchar](200) NULL,
	[Zodiac] [nvarchar](200) NULL,
	[Constellation] [nvarchar](200) NULL,
	[BirthDate] [nvarchar](200) NULL,
	[Marry] [nvarchar](200) NULL,
	[PoliticalID] [nvarchar](200) NULL,
	[NationalID] [nvarchar](200) NULL,
	[NativePlace] [nvarchar](200) NULL,
	[OrderBy] [int] NULL,
	[AddTime] [datetime] NOT NULL  default(getdate()),
PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'User'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'所属租户' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'TenantId'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'软删除' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'IsDelete'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'软删除用户' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'DeleteUserID'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'软删除时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'DeleteTime'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户登录帐号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'Account'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'密码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'Password'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户姓名' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'Name'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'性别' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'Sex'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'用户状态' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'Status'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'手机' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'Mobile'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'电子邮箱' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'Email'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'国籍/地区' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'Nationality'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'宗教信仰' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'Faith'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'健康状况' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'Health'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'证件类型' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'IdcardType'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'证件号码' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'Idcard'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'邮寄地址' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'Address'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'邮编' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'Zipcode'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'生肖' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'Zodiac'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'星座' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'Constellation'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'出生年月日' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'BirthDate'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'婚姻状态' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'Marry'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'政治面貌' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'PoliticalID'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'名族' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'NationalID'
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'籍贯' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'User', @level2type=N'COLUMN',@level2name=N'NativePlace'
GO
--计划任务
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[OpenJob]') AND type IN ('U'))
	DROP TABLE [dbo].[OpenJob]
GO
CREATE TABLE [dbo].[OpenJob] (
  [ID] [varchar](255) primary key DEFAULT(NEWID()) ,--ID
  [JobName] varchar(200) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [RunCount] int DEFAULT ((0)) NOT NULL,
  [ErrorCount] int DEFAULT ((0)) NOT NULL,
  [NextRunTime] datetime  NULL,
  [LastRunTime] datetime  NULL,
  [LastErrorTime] datetime  NULL,
  [JobType] int DEFAULT ((0)) NOT NULL,
  [JobCall] varchar(500) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [JobCallParams] varchar(500) COLLATE Chinese_PRC_CI_AS  NULL,
  [Cron] varchar(50) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [Status] int DEFAULT ((0)) NOT NULL,
  [Remark] varchar(128) COLLATE Chinese_PRC_CI_AS  NULL,
  [CreateTime] datetime DEFAULT (getdate()) NOT NULL,
  [CreateUserId] varchar(50) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [CreateUserName] varchar(200) COLLATE Chinese_PRC_CI_AS  NOT NULL,
  [UpdateTime] datetime  NULL,
  [UpdateUserId] varchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
  [UpdateUserName] varchar(200) COLLATE Chinese_PRC_CI_AS  NULL,
  [OrgId] varchar(50) COLLATE Chinese_PRC_CI_AS  NULL
)
GO
EXEC sp_addextendedproperty'MS_Description', N'Id','SCHEMA', N'dbo','TABLE', N'OpenJob','COLUMN', N'Id'
GO
EXEC sp_addextendedproperty'MS_Description', N'任务名称','SCHEMA', N'dbo','TABLE', N'OpenJob','COLUMN', N'JobName'
GO
EXEC sp_addextendedproperty'MS_Description', N'任务执行次数','SCHEMA', N'dbo','TABLE', N'OpenJob','COLUMN', N'RunCount'
GO
EXEC sp_addextendedproperty
'MS_Description', N'异常次数',
'SCHEMA', N'dbo',
'TABLE', N'OpenJob',
'COLUMN', N'ErrorCount'
GO

EXEC sp_addextendedproperty
'MS_Description', N'下次执行时间',
'SCHEMA', N'dbo',
'TABLE', N'OpenJob',
'COLUMN', N'NextRunTime'
GO

EXEC sp_addextendedproperty
'MS_Description', N'最后一次执行时间',
'SCHEMA', N'dbo',
'TABLE', N'OpenJob',
'COLUMN', N'LastRunTime'
GO

EXEC sp_addextendedproperty
'MS_Description', N'最后一次失败时间',
'SCHEMA', N'dbo',
'TABLE', N'OpenJob',
'COLUMN', N'LastErrorTime'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务执行方式0：本地任务；1：外部接口任务',
'SCHEMA', N'dbo',
'TABLE', N'OpenJob',
'COLUMN', N'JobType'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务地址',
'SCHEMA', N'dbo',
'TABLE', N'OpenJob',
'COLUMN', N'JobCall'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务参数，JSON格式',
'SCHEMA', N'dbo',
'TABLE', N'OpenJob',
'COLUMN', N'JobCallParams'
GO

EXEC sp_addextendedproperty
'MS_Description', N'CRON表达式',
'SCHEMA', N'dbo',
'TABLE', N'OpenJob',
'COLUMN', N'Cron'
GO

EXEC sp_addextendedproperty
'MS_Description', N'任务运行状态（0：停止，1：正在运行，2：暂停）',
'SCHEMA', N'dbo',
'TABLE', N'OpenJob',
'COLUMN', N'Status'
GO

EXEC sp_addextendedproperty
'MS_Description', N'备注',
'SCHEMA', N'dbo',
'TABLE', N'OpenJob',
'COLUMN', N'Remark'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'OpenJob',
'COLUMN', N'CreateTime'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人ID',
'SCHEMA', N'dbo',
'TABLE', N'OpenJob',
'COLUMN', N'CreateUserId'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人',
'SCHEMA', N'dbo',
'TABLE', N'OpenJob',
'COLUMN', N'CreateUserName'
GO

EXEC sp_addextendedproperty
'MS_Description', N'最后更新时间',
'SCHEMA', N'dbo',
'TABLE', N'OpenJob',
'COLUMN', N'UpdateTime'
GO

EXEC sp_addextendedproperty
'MS_Description', N'最后更新人ID',
'SCHEMA', N'dbo',
'TABLE', N'OpenJob',
'COLUMN', N'UpdateUserId'
GO

EXEC sp_addextendedproperty
'MS_Description', N'最后更新人',
'SCHEMA', N'dbo',
'TABLE', N'OpenJob',
'COLUMN', N'UpdateUserName'
GO

EXEC sp_addextendedproperty 'MS_Description', N'所属部门','SCHEMA', N'dbo','TABLE', N'OpenJob','COLUMN', N'OrgId'
GO

EXEC sp_addextendedproperty 'MS_Description', N'定时任务','SCHEMA', N'dbo','TABLE', N'OpenJob'
GO
-- ----------------------------
-- Records of OpenJob
-- ----------------------------
INSERT INTO [dbo].[OpenJob] ([Id], [JobName], [RunCount], [ErrorCount], [NextRunTime], [LastRunTime], [LastErrorTime], [JobType], [JobCall], [JobCallParams], [Cron], [Status], [Remark], [CreateTime], [CreateUserId], [CreateUserName], [UpdateTime], [UpdateUserId], [UpdateUserName], [OrgId]) VALUES (N'f40fe48d-71a4-4f47-b324-6178d97abfb9', N'定时日志任务', N'0', N'0', N'2020-04-25 12:16:19.767', N'2020-04-25 12:16:19.767', N'2020-04-25 12:16:19.767', N'0', N'OpenAuth.App.Jobs.SysLogJob', N'null', N'0/10 * * * * ?', N'0', N'这是个每10秒运行一次的任务，可以在系统日志中查看运行结果', N'2020-04-25 12:16:19.770', N'00000000-0000-0000-0000-000000000000', N'超级管理员', N'2020-04-25 19:31:37.503', N'00000000-0000-0000-0000-000000000000', N'超级管理员', N'')
GO
--系统日志
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[SysLog]') AND type IN ('U'))
	DROP TABLE [dbo].[SysLog]
GO

CREATE TABLE [dbo].[SysLog] (
  [ID] [varchar](255) primary key DEFAULT(NEWID()) ,--ID
  [Content] nvarchar(1000) COLLATE Chinese_PRC_CI_AS  NULL,
  [TypeName] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [TypeId] nvarchar(200) COLLATE Chinese_PRC_CI_AS  NULL,
  [Href] varchar(200) COLLATE Chinese_PRC_CI_AS  NULL,
  [CreateTime] datetime DEFAULT (getdate()) NOT NULL,
  [CreateId] nvarchar(200) COLLATE Chinese_PRC_CI_AS  NULL,
  [CreateName] nvarchar(200) COLLATE Chinese_PRC_CI_AS  NULL,
  [Ip] varchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [Result] int DEFAULT ((0)) NOT NULL,
  [Application] nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL  ,
  [Status] [int] NULL,
  [OrderBy] [int] NULL,
  [AddTime] [datetime] NOT NULL default(getdate()),
)
GO

EXEC sp_addextendedproperty
'MS_Description', N'Id',
'SCHEMA', N'dbo',
'TABLE', N'SysLog',
'COLUMN', N'Id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'日志内容',
'SCHEMA', N'dbo',
'TABLE', N'SysLog',
'COLUMN', N'Content'
GO

EXEC sp_addextendedproperty
'MS_Description', N'分类名称',
'SCHEMA', N'dbo',
'TABLE', N'SysLog',
'COLUMN', N'TypeName'
GO

EXEC sp_addextendedproperty
'MS_Description', N'分类ID',
'SCHEMA', N'dbo',
'TABLE', N'SysLog',
'COLUMN', N'TypeId'
GO

EXEC sp_addextendedproperty
'MS_Description', N'操作所属模块地址',
'SCHEMA', N'dbo',
'TABLE', N'SysLog',
'COLUMN', N'Href'
GO

EXEC sp_addextendedproperty
'MS_Description', N'记录时间',
'SCHEMA', N'dbo',
'TABLE', N'SysLog',
'COLUMN', N'CreateTime'
GO

EXEC sp_addextendedproperty
'MS_Description', N'操作人ID',
'SCHEMA', N'dbo',
'TABLE', N'SysLog',
'COLUMN', N'CreateId'
GO

EXEC sp_addextendedproperty
'MS_Description', N'操作人',
'SCHEMA', N'dbo',
'TABLE', N'SysLog',
'COLUMN', N'CreateName'
GO

EXEC sp_addextendedproperty
'MS_Description', N'操作机器的IP地址',
'SCHEMA', N'dbo',
'TABLE', N'SysLog',
'COLUMN', N'Ip'
GO

EXEC sp_addextendedproperty
'MS_Description', N'操作的结果：0：成功；1：失败；',
'SCHEMA', N'dbo',
'TABLE', N'SysLog',
'COLUMN', N'Result'
GO

EXEC sp_addextendedproperty
'MS_Description', N'所属应用',
'SCHEMA', N'dbo',
'TABLE', N'SysLog',
'COLUMN', N'Application'
GO

EXEC sp_addextendedproperty
'MS_Description', N'系统日志',
'SCHEMA', N'dbo',
'TABLE', N'SysLog'
GO


-- 系统消息
IF EXISTS (SELECT * FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[SysMessage]') AND type IN ('U'))
	DROP TABLE [dbo].[SysMessage]
GO
CREATE TABLE [dbo].[SysMessage] (
  [ID] [varchar](255) primary key DEFAULT(NEWID()) ,--ID
  [TypeName] nvarchar(20) COLLATE Chinese_PRC_CI_AS  NULL,
  [TypeId] nvarchar(200) COLLATE Chinese_PRC_CI_AS  NULL,
  [FromId] nvarchar(200) COLLATE Chinese_PRC_CI_AS  NULL,
  [ToId] nvarchar(200) COLLATE Chinese_PRC_CI_AS  NULL,
  [FromName] nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
  [ToName] nvarchar(50) COLLATE Chinese_PRC_CI_AS  NULL,
  [FromStatus] int DEFAULT ((0)) NOT NULL,
  [ToStatus] int DEFAULT ((0)) NOT NULL,
  [Href] varchar(200) COLLATE Chinese_PRC_CI_AS  NULL,
  [Title] nvarchar(200) COLLATE Chinese_PRC_CI_AS  NULL,
  [Content] nvarchar(1000) COLLATE Chinese_PRC_CI_AS  NULL,
  [CreateTime] datetime DEFAULT (getdate()) NOT NULL,
  [CreateId] nvarchar(200) COLLATE Chinese_PRC_CI_AS  NULL,
)
GO

ALTER TABLE [dbo].[SysMessage] SET (LOCK_ESCALATION = TABLE)
GO

EXEC sp_addextendedproperty
'MS_Description', N'Id',
'SCHEMA', N'dbo',
'TABLE', N'SysMessage',
'COLUMN', N'Id'
GO

EXEC sp_addextendedproperty
'MS_Description', N'分类名称',
'SCHEMA', N'dbo',
'TABLE', N'SysMessage',
'COLUMN', N'TypeName'
GO

EXEC sp_addextendedproperty
'MS_Description', N'分类ID',
'SCHEMA', N'dbo',
'TABLE', N'SysMessage',
'COLUMN', N'TypeId'
GO

EXEC sp_addextendedproperty
'MS_Description', N'消息源头',
'SCHEMA', N'dbo',
'TABLE', N'SysMessage',
'COLUMN', N'FromId'
GO

EXEC sp_addextendedproperty
'MS_Description', N'到达',
'SCHEMA', N'dbo',
'TABLE', N'SysMessage',
'COLUMN', N'ToId'
GO

EXEC sp_addextendedproperty
'MS_Description', N'消息源头名称',
'SCHEMA', N'dbo',
'TABLE', N'SysMessage',
'COLUMN', N'FromName'
GO

EXEC sp_addextendedproperty
'MS_Description', N'消息到达名称',
'SCHEMA', N'dbo',
'TABLE', N'SysMessage',
'COLUMN', N'ToName'
GO

EXEC sp_addextendedproperty
'MS_Description', N'-1:已删除；0:默认',
'SCHEMA', N'dbo',
'TABLE', N'SysMessage',
'COLUMN', N'FromStatus'
GO

EXEC sp_addextendedproperty
'MS_Description', N'-1:已删除；0:默认未读；1：已读',
'SCHEMA', N'dbo',
'TABLE', N'SysMessage',
'COLUMN', N'ToStatus'
GO

EXEC sp_addextendedproperty
'MS_Description', N'点击消息跳转的页面等',
'SCHEMA', N'dbo',
'TABLE', N'SysMessage',
'COLUMN', N'Href'
GO

EXEC sp_addextendedproperty
'MS_Description', N'消息标题',
'SCHEMA', N'dbo',
'TABLE', N'SysMessage',
'COLUMN', N'Title'
GO

EXEC sp_addextendedproperty
'MS_Description', N'消息内容',
'SCHEMA', N'dbo',
'TABLE', N'SysMessage',
'COLUMN', N'Content'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建时间',
'SCHEMA', N'dbo',
'TABLE', N'SysMessage',
'COLUMN', N'CreateTime'
GO

EXEC sp_addextendedproperty
'MS_Description', N'创建人ID',
'SCHEMA', N'dbo',
'TABLE', N'SysMessage',
'COLUMN', N'CreateId'
GO

EXEC sp_addextendedproperty
'MS_Description', N'系统消息表',
'SCHEMA', N'dbo',
'TABLE', N'SysMessage'
GO
